package com.yc.sole.financial.request;

import com.yc.sole.common.enums.PaymentMethod;
import com.yc.sole.framework.validate.SaveGroup;
import com.yc.sole.framework.validate.UpdateGroup;
import jakarta.validation.Valid;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author yizuomin
 * @date 2024/3/21 12:09
 **/
@Data
public class ReceiptBatchReq {

    /**
     * 客户id
     */
    @NotNull(groups = {SaveGroup.class, UpdateGroup.class})
    private Long customerId;
    /**
     * 收款方式 0现金支付 1微信支付 2支付宝支付 3银行卡转账
     */
    @NotNull(groups = {SaveGroup.class, UpdateGroup.class})
    private PaymentMethod receiptMethod;
    /**
     * 收款日期
     */
    @Length(max = 10, groups = {SaveGroup.class, UpdateGroup.class})
    @NotBlank(groups = {SaveGroup.class, UpdateGroup.class})
    private String receiptDate;
    /**
     * 详情
     */
    @Valid
    @NotEmpty(groups = {SaveGroup.class, UpdateGroup.class})
    private List<ReceiptBatchDetailReq> dataList;

    @Data
    public static class ReceiptBatchDetailReq implements Serializable {
        /**
         * 关联订单id
         */
        @NotNull(groups = {SaveGroup.class, UpdateGroup.class})
        private Long orderId;
        /**
         * 回款金额
         */
        @NotNull(groups = {SaveGroup.class, UpdateGroup.class})
        @DecimalMin(value = "0.01")
        private BigDecimal amount;
        /**
         * 备注
         */
        @Length(max = 255, groups = {SaveGroup.class, UpdateGroup.class})
        private String remark;
    }
}
